new Vue({
    el: '#app',
    data() {
        return {
            IO_form: {
                Organization_SerialNumber: "",
                Organization_Name: "",
                Organization_Introduce: "",
                Enterprise_Info_SerialNumber: $.cookie("enterprise"),
                Children: {
                    employee_department: [
                        {
                            Department_SerialNumber: "",
                            Organization_SerialNumber: "",
                            Department_Name: "",
                            Department_Introduce: "",
                        }
                    ]
                }
            },
            formData: {},
            total: 1,
            dialogForm: false,
            title: '',
            multipleSelection: [],
            options: [{
                value: '选项1',
                label: '黄金糕'
            }, {
                value: '选项2',
                label: '双皮奶'
            }, {
                value: '选项3',
                label: '蚵仔煎'
            }, {
                value: '选项4',
                label: '龙须面'
            }, {
                value: '选项5',
                label: '北京烤鸭'
            }],
            defaultProps: {
                children: 'children',
                label: 'label'
            },
            IB_loading: false
        }
    },
    mounted() {
    },
    methods: {
        AddEmployee() {
            this.IO_form.Children.employee_department.push({
                Department_SerialNumber: "",
                Organization_SerialNumber: "",
                Department_Name: "",
                Department_Introduce: "",
            })
        },
        RdcEmployee() {
            if (this.IO_form.Children.employee_department.length > 1) {
                this.IO_form.Children.employee_department.pop()
            } else {
                this.$message({
                    message: '不可以再删除了!',
                    type: 'warning'
                });
            }
        },
        submitForm(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    const this_ = this
                    this.IB_loading = true
                    console.log(this.IO_form)
                    $.ajax({
                        url: DomainName + '/getAddAction',
                        type: 'POST',
                        data: {
                            Data: JSON.stringify({ "employee_organization": [this_.IO_form] }),
                            token: $.cookie("token")
                        },
                        success: function (res) {
                            this_.IB_loading = false
                            console.log(res)
                            if (res.Status == 'success') {
                                this_.$message('添加成功')
                                window.history.go(-1);
                            }
                        }
                    })
                } else {
                    this.$message({
                        message: '请检查表单信息是否有漏填或填写不正确!',
                        type: 'error'
                    });
                    return false;
                }
            });
        },
        back() {
            window.history.go(-1)
        }
    },
})